package com.thememaker.util;

import com.thememake.util.FileUtils;
import com.thememake.util.ThemeImageInfoModel;
import com.thememake.util.image.changesize.ImageChangeSizeUtils;
import com.thememake.util.image.changesize.scaler.ImageScalerUtils;
import com.thememake.util.image.changesize.scaler.ScreenDensity;
import com.thememake.util.xml.XmlUtils;
import com.thememake.util.xml.bean.Dir25;
import com.thememake.util.xml.bean.Dir30;
import com.thememake.util.xml.bean.Image;
import com.thememake.util.xml.bean.VivoConverConfig;

import javax.xml.bind.JAXBException;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;

/**
 * Created by jiajun.jiang on 2017/3/7.
 */
public class ImageChangeDensityUtil {

    public final static String[] densityDirs = {
        "480","720","1080","1440"
    };

    public static void doScale480Image(Path sourceFile,Path targetFile,String dirName){
        try {
            checkDir(targetFile.getParent());
            switch (dirName){
                case "480":
                    ImageChangeSizeUtils.ImageChangeSize(sourceFile.toString(),targetFile.toString(),480,854);
                    break;
                case "720":
                    ImageChangeSizeUtils.ImageChangeSize(sourceFile.toString(),targetFile.toString(),720,1280);
                    break;
                case "1080":
                    ImageChangeSizeUtils.ImageChangeSize(sourceFile.toString(),targetFile.toString(),1080,1920);
                    break;
                case "1440":
                    ImageChangeSizeUtils.ImageChangeSize(sourceFile.toString(),targetFile.toString(),1440,2560);
                    break;
            }


        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void checkDir(Path path) throws IOException {
        if (!Files.exists(path)){
//            System.out.println("创建文件夹 >>> " + path.getFileName());
            Files.createDirectories(path);
        }
    }
}
